<?php
error_reporting("E_ERROR");
require_once "Mail.php";
require_once "config.php";


//Setari SMTP

	function tpl_mail($text)
	{		
		
		$return = '    <html>
    <head>
    </head>
    
    <body >
    
    <img src="http://hackrogov.cloudapp.net/posturi/res/img/banner.png" width="650">
    <div style="border-bottom: solid 1px #000;height:10px; width:650px">
    </div>';
	
	
		
		$return .= $text;
		
		$return .='<div style="border-bottom: solid 1px #000;height:10px; width:650px">
    </div>
    
    <div style="font-size:10px; ">
        Primesti acest mesaj deoarece esti abonat la newsleterul <a href="http://posturi.gov.ro/">posturi.gov.ro.</a></br>
        Nu mai esti interesat? <a href=#> Dezaboneaza-te instant.</a></br></br>
        Copyright &copy; 2013 <a href="http://gov.ro/">Guvernul Romaniei</a>
    </div>
    </body>
    </html>';
	
		return $return;
		
		
	}

function send_mail($to,$subject,$body){
	global $smtp_host;
	global $smpt_port;
	global $smtp_username;
	global $smtp_password;
	global $smtp_from;


	$from = $smtp_from;
	
	$host =$smtp_host;
	$port = $smpt_port;
	$username = $smtp_username;
	$password = $smtp_password;
	
	$headers = array ('From' => $from,
	  'To' => $to,
	  'Subject' => $subject);
	$smtp = Mail::factory('smtp',
	  array ('host' => $host,
		'port' => $port,
		'auth' => true,
		'username' => $username,
		'password' => $password));
	
	$mail = $smtp->send($to, $headers, tpl_mail($body));
	
	if (PEAR::isError($mail)) {
	  echo("<p>" . $mail->getMessage() . "</p>");
	 } else {
	  echo("<p>Message successfully sent!</p>");
	 }
 
}

function safe_text($text){
	
	return strip_tags($text);
}

if($_GET['send'])
send_mail("m.hatisi@gmail.com","Test","Gov");

?>